package com.learn.designPatterns.behavioral.command;

/**
 * @classname:
 * @Description:
 * @author: yfpu
 * @Date: 2018-09-12 19:56
 */
public class Invoker {

    private Command[] onCommands;
    private Command[] offCommands;
    private int slotNum = 7;

    public Invoker() {
        onCommands = new Command[slotNum];
        offCommands = new Command[slotNum];
    }

    public void setOnCommand(Command command, int slot) {
        onCommands[slot] = command;
    }

    public void setOffCommand(Command command, int slot) {
        onCommands[slot] = command;
    }

    public void onButtonWasPushed(int slot) {
        onCommands[slot].execute();
    }

    public void offButtonWasPushed(int slot) {
        offCommands[slot].execute();
    }


}
